﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RabbitMQ_Test2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //var a = new Form();
            //DateTime t1 = DateTime.Now;
            //for(long i=0;i<10000000000;i++)
            //{
            //    object x = a;
            //}
            //var t = (DateTime.Now - t1).TotalMilliseconds;
            //if(t>0)
            //{
            //    return;
            //}
        }
        private double time = 0;
        private async void button1_Click(object sender, EventArgs e)
        {
            bool? value1 = false;
            string value2 = null;

            StringBuilder Text = new StringBuilder();
            List<bool?> values = new List<bool?>();
            for (int j = 0; j < 10; j++)
            {
                using (var rmqu1 = new RabbitMQUtility("crm_customer", "crm", "172.16.251.187", 5673, "ycgwlrmq", "123abc~~~", "rabbitmq1.rabbit.com", "ycgwl_crm_vhost"))
                {

                    for (int i = 0; i < 6; i++)
                    {

                        value1 = await rmqu1.Producer("测试" + DateTime.Now.ToString() + System.Guid.NewGuid().ToString());
                    }
                }
            }
            return;
            ////    //rmqu1 = new RabbitMQUtility("synchronization_table2", "ycgwl_crm", "172.16.251.187", 5673, "ycgwlrmq", "123abc~~~", "rabbitmq1.rabbit.com", "ycgwl_crm_vhost");
            ////    for (int i = 0; i < 10 * 1; i++)
            ////    {

            ////        value1 = await rmqu1.Producer("测试" + DateTime.Now.ToString());
            ////    }
            //}
            //for (int i = 0; i < 10; i++)
            //{test_virtual_host test_exchange topic D  
            using (var rmqu = new RabbitMQUtility("testqueue1", "test1", "172.16.254.221", 5673, "rmq", "123abc", "rabbitmq1.rabbit.com", "rmq_virtual_host", "*", "fanout"))
            {
                using (var rmqu2 = new RabbitMQUtility("testqueue2", "test1", "172.16.254.221", 5673, "rmq", "123abc", "rabbitmq1.rabbit.com", "rmq_virtual_host", "*", "fanout"))
                {
                    using (var rmqu3 = new RabbitMQUtility("testqueue3", "test1", "172.16.254.221", 5673, "rmq", "123abc", "rabbitmq1.rabbit.com", "rmq_virtual_host", "*", "fanout"))
                    {
                        await rmqu2.Producer(Guid.NewGuid().ToString());
                        await rmqu.Producer(Guid.NewGuid().ToString());
                        await rmqu3.Producer(Guid.NewGuid().ToString());
                        values = new List<bool?>();
                        for (int i = 0; i < 100; i++)
                        {

                            //values.Add(await rmqu2.Producer(Guid.NewGuid().ToString()));

                            values.Add(await rmqu.Producer(Guid.NewGuid().ToString()));
                        }
                        //List<string> sss = await rmqu.Consumer(100);
                        //int x = sss.Count();
                        //foreach (var item in sss)
                        //{
                        //    this.textBox1.Text += (item + System.Environment.NewLine);
                        //}
                        //List<int> s1 = new List<int>();
                        //List<int> s2 = new List<int>();
                        //List<int> s3 = new List<int>();
                        //s1.Where(a => (a > 0 ? s2.Add(a),false : s3.Add(a),false));
                        //for (int j = 0; j < 100; j++)
                        //{

                        //    DateTime t1 = DateTime.Now;

                        //    //value1 = await rmqu.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    //value1 = await RabbitMQUtility.Producer("测试" + DateTime.Now.ToString());
                        //    value2 = await rmqu.Consumer();
                        //    Text.Insert(0, System.Environment.NewLine);
                        //    Text.Insert(0, j);
                        //    Text.Insert(0, "_");
                        //    Text.Insert(0, i);
                        //    Text.Insert(0, "_");
                        //    Text.Insert(0, value2);
                        //    this.textBox1.Text = Text.ToString();
                        //    DateTime t2 = DateTime.Now;
                        //    TimeSpan t = t2 - t1;
                        //    time += t.TotalMilliseconds;
                        //    this.label1.Text = time.ToString();
                        //    await Task.Delay(0);
                        //}
                        //}
                        //await Task.Delay(100);

                    }
                    //this.textBox1.Text = Text.ToString();
                    //this.label1.Text = time + "";

                }
            }

        }

    }
}
